﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ThongTinSV
{
    public partial class TTSV : Form
    {
        double toan, van, anh, them, min, tk;
        void tinh()
        {
            toan = double.Parse(txtToan.Text);
            van = double.Parse(txtVan.Text);
            anh = double.Parse(txtAnh.Text);



            //check gioi tinh
            if (rdoNam.Checked == true)
            {
                them = 0;
            }
            if (rdoNu.Checked == true)
            {
                them = 0.5;
            }
            txtThem.Text = them.ToString();
            tk = van * 2 + toan * 2 + anh + them;
            txtTK.Text = tk.ToString();

            //diem thap nhat
            min = toan;
            if (min > van)
            {
                min = van;
            }
            if (min > anh)
            {
                min = anh;
            }
            txtDTN.Text = min.ToString();

            //xeploai
            if (tk >= 40 && min >= 7)
            {
                txtXL.Text = "Gioi";
            }
            else
                if (tk >= 35 && min >= 6)
                {
                    txtXL.Text = "Kha";
                }
                else
                    if (tk >= 25 && min >= 5)
                    {
                        txtXL.Text = "TB";
                    }
                    else
                        txtXL.Text = "Yeu";

        }
        void xoa()
        {
            toan = 0;
            van = 0;
            anh = 0;
            them = 0;
            min = 0;
            tk = 0;
            txtAnh.Text = "";
            txtDTN.Text = "";
            txtTen.Text = "";
            txtThem.Text = "";
            txtTK.Text = "";
            txtToan.Text = "";
            txtVan.Text = "";
            txtXL.Text = "";

        }
        public TTSV()
        {
            InitializeComponent();
        }

        private void btnTinh_Click(object sender, EventArgs e)
        {
            tinh();
        }

        private void btnDung_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void txt_TextChanged(object sender, EventArgs e)
        {
            TextBox A = (TextBox)sender;
            double a;
            try
            {
                if (A.Text == ".")
                {
                    return;
                }
                a = double.Parse(A.Text);
                if (a > 10 || a < 0)
                {
                    MessageBox.Show("dang hack ha???");
                    A.Text = "";

                }
            }
            catch (Exception)
            {
                A.Text = "";
            }
        }
    }
}
